using System.Collections.Generic;
using System.Data;

namespace Nvigorate.Test.Comparer
{
    public class DbDataParameterEqualityComparer : IEqualityComparer<IDbDataParameter>
    {
        public bool Equals(IDbDataParameter x, IDbDataParameter y)
        {
            if (ReferenceEquals(x, y)) return true;
            if (x == null || y == null) return false;

            return x.ParameterName.Equals(y.ParameterName) && x.Value.Equals(y.Value);
        }

        public int GetHashCode(IDbDataParameter obj)
        {
            if (obj == null) return 0;
            int hash = 29*(obj.ParameterName == null ? 0 : obj.ParameterName.GetHashCode());
            hash += (obj.Value == null) ? 0 : 29*obj.Value.GetHashCode();

            return hash;
        }
    }
}